package com.ming.springboot.security;

import com.alibaba.fastjson.JSON;
import com.ming.springboot.data.Result;
import com.ming.springboot.data.ResultCode;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by mqsi on 2022/5/24 19:44
 */
@Component
public class SelfLogoutSuccessHandler implements LogoutSuccessHandler {
	@Override
	public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
		Result message = Result.message(ResultCode.LOGOUT_SUCCESS, "Logout Success");
		response.getWriter().write(JSON.toJSONString(message));
	}
}
